//
//  PBProgressView.m
//  ProjectBoss
//
//  Created by 聂志康 on 2018/6/25.
//  Copyright © 2018年 weipainetwork. All rights reserved.
//

#import "PBProgressView.h"

@interface PBProgressView ()
{
    CGRect _frame;
}
@property (nonatomic, strong) UIView *borderView;
@property (nonatomic, strong) UIView *contentView;
@end

@implementation PBProgressView

- (instancetype)initWithFrame:(CGRect)frame borderColor:(UIColor *)borderColor contentColor:(UIColor *)color {
    self= [super initWithFrame:frame];
    if (self) {
        _frame = frame;
        UIView *borderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        self.borderView = borderView;
        borderView.backgroundColor = [UIColor whiteColor];
        borderView.layer.cornerRadius = kHeight(5)/2;
        borderView.layer.masksToBounds = YES;
        borderView.layer.borderColor = borderColor.CGColor;
        borderView.layer.borderWidth = 1.0;
        [self addSubview:borderView];
        UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, frame.size.height)];
        contentView.backgroundColor = color;
        self.contentView = contentView;
        [borderView addSubview:contentView];
    }
    return self;
}

- (void)setProgress:(CGFloat)progress {
    _progress = progress;
    self.contentView.frame = CGRectMake(0, 0, _frame.size.width*progress, _frame.size.height);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
